

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


import lex.Printer;
import lex.Lexer;
import lex.Token;


public class Main
{


	public static void main(String[] args)

	{
		List<Token> tokens = new LinkedList<Token>();
		Lexer lex = new Lexer();
		Printer pr = null;
		
		String input_line = null;
		String fname = args[0];
		
		File file = new File(fname);
		FileReader 	fr = null;

		try {
			fr = new FileReader(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		Scanner sc = new Scanner(fr);


		while(sc.hasNext()){
			
			input_line = sc.nextLine();

			try {
				lex.process(input_line, tokens);	
			}
			catch (Exception e) {
				System.err.println(e);
			}
		}

		
		pr = new Printer(input_line, tokens);
		pr.print();
	}
}